import {
	mapGetters
} from "vuex"

export default {
	computed: {
		...mapGetters('m_cart', ['total'])
	},
	onShow() {
		// 初次展示时赋值
		this.cartTabBarBadge();
	},
	watch: {
		// 当total值发生变化时赋值
		total() {
			this.cartTabBarBadge();
		}
	},
	methods: {
		// 给购物车的tabbar的徽标赋值
		cartTabBarBadge() {
			uni.setTabBarBadge({
				index: 2,
				text: this.total + ''
			});
		}
	}
}
